/**
 * @author Stefan Riedel
 */

var tabPanelTemplate = '<section></section>';

$(function(){
    $("article").resizable();
        
    // Accordion
    var active = $('h3.active');
    if(active.length > 0) {
        $("#accordion").accordion({
            header: 'h3',
            fillSpace: true,
            active: active
        });
    }
    else {
        $("#accordion").accordion({
            header: 'h3',
            fillSpace: true
        });
    }
        
    // Tabs
    //$('#form-assign-tabs').tabs().find('.ui-tabs-nav').sortable({ axis: 'x', panelTemplate: '<section></section>' });

    $('#content-bar').tabs().find(".ui-tabs-nav").sortable({
        axis: 'x',
        panelTemplate: '<section></section>'
    });


    $('#addTab').click(function(event) {
        event.preventDefault();

        $('#tabs').tabs('add', '', 'a label');
    });
    
    $('#detailCloseBtn a').click(function(event) {
        event.preventDefault();
        $('#detail').effect('fold');
        $('#main').css('width', '80%');
    });

    $('tr.js-changer').live('mouseover', function(event) {
    	$(this).addClass('hover');
    }).live('mouseout', function(event){
    	$(this).removeClass('hover');
    }).live('dblclick', function(event){
    	var rel = $(this).attr("rel");
    	if(rel != undefined) {
    		location.href = rel;
    	}
    });
    
    $('.ui-button').live('mouseover', function(event) {
        $(this).addClass('ui-state-active');
    }).live('mouseout', function(event) {
        $(this).removeClass('ui-state-active');
    });

});
